package com.moloon.game.sanguo.editor.propseditor.view.mission;

import org.eclipse.jface.action.IToolBarManager;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.forms.widgets.FormToolkit;
import org.eclipse.ui.forms.widgets.ScrolledForm;
import org.eclipse.ui.forms.widgets.Section;
import org.eclipse.ui.part.ViewPart;

public class MissionFormView extends ViewPart {
	public MissionFormView() {
	}

	public static final String ID = "PropsEditor.missionFormView";
	private FormToolkit toolkit;
	private ScrolledForm form;

	public void createPartControl(Composite parent) {
		System.currentTimeMillis();
		toolkit = new FormToolkit(parent.getDisplay());
		initializeToolBar();
		form = toolkit.createScrolledForm(parent);
		final Composite body = form.getBody();
		form.setText("任务");
		GridLayout layout = new GridLayout();
		layout.numColumns = 2;
		// layout.makeColumnsEqualWidth = true;
		form.getBody().setLayout(layout);

		// This call is needed because the section will compute
		// the bold version based on the parent.
		Dialog.applyDialogFont(form.getBody());

		final MissionBaseSection missionBaseSection = new MissionBaseSection(
				body, toolkit, Section.TWISTIE | Section.TITLE_BAR
						| Section.EXPANDED);
		Section section = missionBaseSection.getSection();
		section.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));

		final MissionGrantSection missionGrantSection = new MissionGrantSection(
				body, toolkit, Section.TWISTIE | Section.TITLE_BAR
						| Section.EXPANDED);
		section = missionGrantSection.getSection();
		section.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));

		final MissionLocationSection missionLocationSection = new MissionLocationSection(
				body, toolkit, Section.TWISTIE | Section.TITLE_BAR
						| Section.EXPANDED);
		section = missionLocationSection.getSection();
		section.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));

		final MissionRequirementSection missionRequirementSection = new MissionRequirementSection(
				body, toolkit, Section.TWISTIE | Section.TITLE_BAR
						| Section.EXPANDED);
		section = missionRequirementSection.getSection();
		section.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));

		form.reflow(true);
	}

	public void setFocus() {
	}

	private void initializeToolBar() {
		IToolBarManager toolBarManager = getViewSite().getActionBars()
				.getToolBarManager();
	}
}
